<template>
  <div style = "padding: 10px">
    <div style = "margin: 10px  0">
  <el-form :model="form" label-width="120px" style="margin: auto">
    <el-form-item label="年级">
      <el-select v-model="form.student_grade " placeholder="选择你的年级">
        <el-option label="2023研一" value="研一" @click="dialogVisible1=true"/>
<!--        <el-option label="2023研二" value="研二" @click="dialogVisible2=true"/>
        <el-option label="2023研三" value="研三" @click="dialogVisible3=true"/>-->
      </el-select>
    </el-form-item>
  </el-form>

  <el-card style="width: 80%;height: 80%; margin-inside: auto" shadow="always">
    <el-form ref="form" :model="form" label-width="100 px">
      <el-form-item label="学号">
        <el-input v-model="form.student_id" ></el-input>
      </el-form-item>
      <el-form-item label="姓名">
        <el-input v-model="form.student_name"  ></el-input>
      </el-form-item>
      <el-form-item label="年份">
        <el-input v-model="form.syear"  ></el-input>
      </el-form-item>
      <el-form-item label="年级">
        <el-input v-model="form.student_grade"  autocomplete="off"></el-input>
      </el-form-item>

    </el-form>
  </el-card>
  <div>
    <!-- 研一-->

    <el-dialog v-model="dialogVisible1" title="研一申报页面" width="50%" >
      <div style="margin: 20px" />
      <el-form :model="form1" label-width="150px">
        <el-form-item   label="学业成绩">
          <el-input  style="width: 90px; height: 80%" v-model="form1.学业成绩" />
        </el-form-item>
      </el-form>
      <div style = "padding: 10px"/>
      <el-form-item label="学术论文" label-width="150px" >
        <el-form-item label="获得 CCF推荐A类国际学术期刊或中科院1区"     >
          <el-input-number v-model="form1.CCF推荐A类国际学术期刊或中科院1区" :precision="0" :step="1" :min="0" :max="10" />

        </el-form-item>

        <div style = "padding: 10px"/>


        <el-form-item label="获得 CCF推荐B类国际学术期刊或中科院2区"   >
          <el-input-number v-model="form1.CCF推荐B类国际学术期刊或中科院2区" :precision="0" :step="1" :min="0" :max="10" />
        </el-form-item>

        <div style = "padding: 10px"/>

        <el-form-item label="获得 CCF推荐C类国际学术期刊或中科院3区">
          <el-input-number v-model="form1.CCF推荐C类国际学术期刊或中科院3区" :precision="0" :step="1" :min="0" :max="10" />
        </el-form-item>

        <div style = "padding: 10px"/>

        <el-form-item label="获得 一般学术期刊">
          <el-input-number v-model="form1.一般学术期刊" :precision="0" :step="1" :min="0" :max="10" />
        </el-form-item>

        <div style = "padding: 10px"/>

        <el-form-item label="学科竞赛           "  label-width="150px"  >
          <el-form-item label="获得 国家级一等奖">
            <el-input-number v-model="form1.国家级一等奖" :precision="0" :step="1" :min="0" :max="10" />
          </el-form-item>
          <div style = "padding: 10px"/>
          <el-form-item label="获得 国家级二等奖">
            <el-input-number v-model="form1.国家级二等奖" :precision="0" :step="1" :min="0" :max="10" />
          </el-form-item>
          <div style = "padding: 10px"/>
          <el-form-item label="获得 国家级三等奖">
            <el-input-number v-model="form1.国家级三等奖" :precision="0" :step="1" :min="0" :max="10" />
          </el-form-item>
          <div style = "padding: 10px"/>
          <el-form-item label="获得 省级一等奖">
            <el-input-number v-model="form1.省级一等奖" :precision="0" :step="1" :min="0" :max="10" />
          </el-form-item>
          <div style = "padding: 10px"/>
          <el-form-item label="获得 省级二等奖">
            <el-input-number v-model="form1.省级二等奖数" :precision="0" :step="1" :min="0" :max="10" />
          </el-form-item>
          <div style = "padding: 10px"/>
          <el-form-item label="获得 省级三等奖">
            <el-input-number v-model="form1.省级三等奖" :precision="0" :step="1" :min="0" :max="10" />
          </el-form-item>
          <div style = "padding: 10px"/>
          <el-form-item label="获得 校赛奖项">
            <el-input-number v-model="form1.校赛奖项" :precision="0" :step="1" :min="0" :max="10" />
          </el-form-item>

<!--       <el-form-item label="附件">
            <el-upload action="/api/files/upload" :on-success="filesUploadSuccess">
              <el-button type="primary">上传</el-button>
            </el-upload>
          </el-form-item>-->
        </el-form-item>
      </el-form-item>
      <template #footer>
      <span class="dialog-footer">
        <el-button @click="dialogVisible1 = false">取消</el-button>
        <el-button type="primary" @click="save1">确定</el-button>
      </span>
      </template>
    </el-dialog>

  </div>
    </div>
  </div>
</template>

<script>

import request from "@/utils/request";
export default {
  name: "Apply",
  components: {},
  data(){
    return{
      grade:'',
      form:{
        student_grade:""
      },
      form1:{
        "科研能力":{}
      },
      tableData:[],
      dialogVisible1:false,
      dialogVisible2:false,
      dialogVisible3:false,

    }
  },
  created(){
    let str = sessionStorage.getItem("student")||"{}"
    this.form = JSON.parse(str)
    this.choose()
  },
  methods:{
    save1(){
      this.form1["姓名"] = this.form.student_name;
      this.form1["学号"] = this.form.student_id;
      this.form1["年份"] = this.form.syear;
      request.post("/apply/Grade1",this.form1).then(res =>{
        console.log(this.form1)
        console.log(this.res)
        this.$message({type: "success", message:"申报成功"})
      })
      this.dialogVisible1 = false
    },

    choose() {
      if (this.form.student_grade  === "研一") {
        this.dialogVisible1 = true;
      } else if (this.form.student_grade  === "研二") {
        this.dialogVisible2 = true;
      } else {
        this.dialogVisible3 = true;
      }
    },

    filesUploadSuccess(res) {
      console.log(res)
      this.form.cover = res.data
    }

}}

</script>

<style scoped>

</style>